/*
-----------------------------------------------------------------------------
This source file is part of the
   ___                 __    __ _ _    _ 
  /___\__ _ _ __ ___  / / /\ \ (_) | _(_)
 //  // _` | '__/ _ \ \ \/  \/ / | |/ / |
/ \_// (_| | | |  __/  \  /\  /| |   <| |
\___/ \__, |_|  \___|   \/  \/ |_|_|\_\_|
      |___/                              
      Tutorial Framework
      http://www.ogre3d.org/tikiwiki/
-----------------------------------------------------------------------------
*/

#ifndef __GameApp_h_
#define __GameApp_h_

//#include <CEGUI/CEGUI.H>
#include <C:/cgt/cgt-lib/CEGUI/cegui/include/CEGUI.h>
//#include <CEGUI/RendererModules/Ogre/CEGUIOgreRenderer.h>
#include <C:/cgt/cgt-lib/CEGUI/cegui/include/RendererModules/Ogre/CEGUIOgreRenderer.h>

#include "BaseApplication.h"
#define NUMPLANES 4
#define NUMSHAPES 9
#define NUM_PLATS 10

class GameApp : public BaseApplication
{
public:
    GameApp(void);
    virtual ~GameApp(void);

protected:
    virtual void createScene(void);
	void virtual createFrameListener(void);
	virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);

	//OIS Keyboard
	virtual bool keyPressed(const OIS::KeyEvent& evt);
    virtual bool keyReleased(const OIS::KeyEvent& evt);

	//OIS Mouse
	virtual bool mouseMoved(const OIS::MouseEvent& evt);
    virtual bool mousePressed(const OIS::MouseEvent& evt, OIS::MouseButtonID id);
    virtual bool mouseReleased(const OIS::MouseEvent& evt, OIS::MouseButtonID id);

	int totalShapes;
	int hiddenInt;
	int cubeInt;
	int sphereInt;
	int tetraInt;
	int tubeInt;
	int maxInt;

	int collide;

	// entities
	Ogre::Entity* platform[NUM_PLATS];	// 4 neutral, 3 up and 3 down platforms
	Ogre::Entity* platCube[NUM_PLATS];
	Ogre::Entity* arrowPlat[NUM_PLATS];

	Ogre::Entity* player;
	Ogre::Entity* hiddenShape;
	Ogre::Entity* planes[NUMPLANES];
	Ogre::Entity* cubes[NUMSHAPES];
	Ogre::Entity* spheres[NUMSHAPES];
	Ogre::Entity* tetrahedrons[NUMSHAPES];
	Ogre::Entity* tubes[NUMSHAPES];

	Ogre::Entity* tempCubes[NUMSHAPES];
	Ogre::Entity* tempSpheres[NUMSHAPES];
	Ogre::Entity* tempTetrahedrons[NUMSHAPES];
	Ogre::Entity* tempTubes[NUMSHAPES];

	Ogre::Real mRotate;          // The rotate constant
    Ogre::Real mMove;            // The movement constant
	Ogre::Vector3 mDirection;    // Value to move in the correct direction

	// scene nodes
	Ogre::SceneNode* platNode[NUM_PLATS];
	Ogre::SceneNode* platCubeNode[NUM_PLATS];
	Ogre::SceneNode* arrowPlatNode[NUM_PLATS];

	Ogre::SceneNode* playerNode;
	Ogre::SceneNode* hiddenNode;
	Ogre::SceneNode* planeNode[NUMPLANES];
	Ogre::SceneNode* cubeNodes[NUMSHAPES];
	Ogre::SceneNode* sphereNodes[NUMSHAPES];
	Ogre::SceneNode* tetraNodes[NUMSHAPES];
	Ogre::SceneNode* tubeNodes[NUMSHAPES];
    Ogre::SceneNode* mCamNode;   // The SceneNode the camera is currently attached to

	// AABB
	Ogre::AxisAlignedBox platBox[NUM_PLATS];
	Ogre::AxisAlignedBox platCubeBox[NUM_PLATS];

	Ogre::AxisAlignedBox pBox;
	Ogre::AxisAlignedBox hiddenBox;
	Ogre::AxisAlignedBox planeBox[NUMPLANES];
	Ogre::AxisAlignedBox cubeBox[NUMSHAPES];
	Ogre::AxisAlignedBox sphereBox[NUMSHAPES];
	Ogre::AxisAlignedBox tetraBox[NUMSHAPES];
	Ogre::AxisAlignedBox tubeBox[NUMSHAPES];

	bool collision;
	bool active;

	CEGUI::OgreRenderer* mRenderer;
	bool quit(const CEGUI::EventArgs &e);

	int guesses;
	Ogre::Light* torch;
	CEGUI::Window* guiWnd;
	CEGUI::Window* guiTorch;
	CEGUI::Window* guiEnd;

private:
	// Process input from Keyboard or mouse
	bool processInput(const Ogre::FrameEvent& evt);
};
#endif // #ifndef __TutorialApplication_h_
